{include(head.tpl)}
<body>
<div class="wrapper-content">
    <div class="animated fadeInDown wrap">
      <div class="btn-box">
          <span class="dib padding-5 radius-3 blue addUser">添加用户</span>
      </div>
        <!--搜索栏-->
        <div class="search">
            标题：<input type="text" placeholder="请输入">
            用户名：<input type="text" placeholder="请输入">
            时间：<input type="datetime-local" placeholder="请输入">
            角色：
            <select>
                <option value="">超级管理员</option>
                <option value="">管理员</option>
                <option value="">发布人员</option>
                <option value="">客户</option>
            </select>
            <input type="submit" class="submit">
        </div>
        <table class="table_value table">
            <tr>
                <th>ID</th>
                <th>头像</th>
                <th>登陆名</th>
                <th>用户名</th>
                <th>角色</th>
                <th>手机</th>
                <th>联系电话</th>
                <th>电子邮件</th>
                <th>在线状态</th>
                <th>是否被锁定</th>
                <th>状态</th>
                <th>上次登陆时间</th>
                <th>注册时间</th>
                <th>操作</th>
            </tr>
            {foreach from=listarr item=vo}
                <tr>
                    <td>{$vo.id}</td>
                    <td><img src="{$vo.face}" style="width:60px;heigth:30px;"></td>
                    <td>{$vo.loginname}</td>
                    <td>{$vo.name}</td>
                    <td>{$vo.rolename}</td>
                    <td>{$vo.mobile}</td>
                    <td>{$vo.telphone}</td>
                    <td>{$vo.mail}</td>
                    <td>{if $vo['online']==1}在线{/else}离线{/if}</td>
                    <td>{if $vo['locked']==1}已锁定{/else}正常{/if}</td>
                    <td>{if $vo['status']==1}正常{/else}已禁止{/if}</td>
                    <td><?php echo date('Y-m-d H:i:s',$vo['lastlogintime']) ;?></td>
                    <td><?php echo date('Y-m-d H:i:s',$vo['regtime']) ;?></td>
                    <td>
                        <span onclick="editUser({$vo.id})" class="dib padding-5 radius-3 orange_2">编辑</span>
                        <span onclick="delUser({$vo.id})"  class="dib padding-5 radius-3 orange">删除</span>
                    </td>
                </tr>
            {/foreach}
        </table>
        <div class="page">{pageshow}</div>
    </div>
</div>

  <script>
  //添加或编辑 回调函数
  function layer_return(){
      layer.close(layer.index);
      window.location.reload();
  }
  //添加用户
  $(function(){
      $('.addUser').click(function(){
        layer.open({
          type: 2,
          title: '创建角色',
          shadeClose: true,
          shade: false,
          maxmin: true, //开启最大化最小化按钮
          area: ['700px', '600px'],
          content:'{ctlurl}/userAdd',
        });
      })
  })
  //编辑用户
  function editUser(id){
    layer.open({
      type: 2,
      title: '创建角色',
      shadeClose: true,
      shade: false,
      maxmin: true, //开启最大化最小化按钮
      area: ['900px', '700px'],
      content:'{ctlurl}/userEdit/id/'+id,
    });
  }
  //删除用户
  function delUser(id){
      var delcolumn_layer=layer.confirm('确认要删除吗！', {btn: ['确认','取消'],'title':'删除栏目'},function(){
            _ajaxs.post('{ctlurl}/userDel','id='+id,function _return(hdata){
                if(hdata.status){
                  layer.msg(hdata.msg,function(){
                      window.location.reload();
                  });
                }else{
                  layer.msg(data.msg);
                }
            })
      },function(){
        layer.close(delcolumn_layer);
      });
  }
  //分页
  function ajaxpage(page){
      var url='page='+page;
      _ajaxs.post('{mothedurl}',url,function _return(hdata){
          var pageh=pagehead();
          var pagec=pagecontent(hdata);
          $('.table_value').html('');
          $('.table_value').html(pageh+pagec);
          $('.page').html('');
          $('.page').html(hdata.data.pageshow);
      })
  }
  function pagehead(){
      var pageheadhtml='  <tr>\
            <th>ID</th>\
            <th>头像</th>\
            <th>登陆名</th>\
            <th>用户名</th>\
            <th>角色</th>\
            <th>手机</th>\
            <th>联系电话</th>\
            <th>电子邮件</th>\
            <th>在线状态</th>\
            <th>是否被锁定</th>\
            <th>状态</th>\
            <th>上次登陆时间</th>\
            <th>注册时间</th>\
            <th>操作</th>\
        </tr>';
      return pageheadhtml;
  }
  function pagecontent(hdata){
      var list=hdata.data.list;
      var pagecontenthtml='';
      if(list!=''){
        for(i=0;i<list.length;i++){
          pagecontenthtml+='  <tr>\
                <td>'+list[i]['id']+'</td>\
                <td><img src="'+list[i]['face']+'" style="width:60px;heigth:30px;"></td>\
                <td>'+list[i]['loginname']+'</td>\
                <td>'+list[i]['name']+'</td>\
                <td>'+list[i]['rolename']+'</td>\
                <td>'+list[i]['mobile']+'</td>\
                <td>'+list[i]['telphone']+'</td>\
                <td>'+list[i]['mail']+'</td>';
                if(list[i]['online']==1){
                      pagecontenthtml+='<td>在线</td>';
                }else{
                      pagecontenthtml+='<td>离线</td>';
                }
                if(list[i]['locked']==1){
                      pagecontenthtml+='<td>已锁定</td>';
                }else{
                      pagecontenthtml+='<td>正常</td>';
                }
                if(list[i]['status']==1){
                      pagecontenthtml+='<td>正常</td>';
                }else{
                      pagecontenthtml+='<td>已禁止</td>';
                }
        pagecontenthtml+='<td>'+_myTime.UnixToDate(list[i]['lastlogintime'],true,8)+'</td>\
                <td>'+_myTime.UnixToDate(list[i]['regtime'],true,8)+'</td>\
                <td>\
                    <span onclick="editUser('+list[i]['id']+')" class="dib padding-5 radius-3 orange_2">编辑</span>\
                    <span onclick="delUser('+list[i]['id']+')"  class="dib padding-5 radius-3 orange">删除</span>\
                </td>\
            </tr>';

        }
      }
      return pagecontenthtml;

  }
  </script>
</body>
</html>
